<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>百商汇</title>
	<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0,minimum-scale = 1.0,user-scalable = no,width = device-width">
	<meta name="format-detection" content="telephone=no" />
	<link rel="stylesheet" type="text/css" href="../csses/upToVIP.css">
</head>
<body>
	<div class="upToVIP_title">
		升级为VIP
		<img src="../image/back.png" onclick="goBack()">
	</div>
	<div class="upToVIP_box">
		<ul class="details_content">
			<li>
				<span>升级金额</span>
				<input type="text" value="100元" readonly="true"></input>
			</li>
			<li>
				<span>支付方式</span>
				<input type="text" placeholder="请选择支付方式" readonly="true" class="payWays"></input>
			</li>
			<li>
				<span>支付密码</span>
				<input type="password" placeholder="请输入百商汇支付密码" class="paypassword input"></input>
			</li>
		</ul>

		<button class="submitBtn">确认</button>
		<p>确认即表示同意<a href="./registerAgree.html">《百商汇用户协议》</a></p>

		<div class="hidden_box">
			<ul>
				<li>请选择充值方式</li>
				<li class="content" value="余额支付">余额支付</li>
			</ul>
		</div>

		<div class="remindBox"></div>
	</div>



	<script type="text/javascript" src="../lib/flexible.js"></script>
	<script type="text/javascript" src="../lib/jquery-1.10.1.min.js"></script>
	<script type="text/javascript">
		function goBack(){
			window.history.back();
		}

		$('.input').focus(function(){
			this.select();
		});


		$('.payWays').click(function(){
			$('.hidden_box').css('display','block');
		});

		$('.content').click(function(){
			$('.payWays').attr('value',$(this).text());
			$('.hidden_box').css('display','none');
		});

		var $remindBox = $('.remindBox');
		
		$('.submitBtn').click(function(){
			var $paypassword = $('.paypassword').val();
			if($('.payWays').val() == '余额支付'){
				$.ajax({
					type : 'post',
					url : '/api/v1/upgrade/member/balance',
					data : {
						paramStr : "{'userName':'" + sessionStorage.userName + "','token':'" + sessionStorage.token + "','paymentType':'" + 'Balance' + "','level':'" + 'vip' + "','paypassword':'" + $paypassword + "'}"
					},
					dataType : 'json',
					timeout : 10000,
					success : function (data) {
						$remindBox.css('display','block');
						$remindBox.text(data.message);
						setTimeout(function(){
							$remindBox.css('display','none');
						},1500)
						if(data.code == 200){
							$('.submitBtn').attr('disabled',true).css('background','#ccc');
							setTimeout(function(){
								window.location.href = '../index1.html#!/personal';
							},1500);
						}
					},
					error : function (xhr,type,errorThrown) {
						// alert('未知错误');
					}
				});
			}
		});
	</script>
</body>
</html>